<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>直播推流控件对象</title>
	</head>
	<body>
		<div>
			<button onclick="setStyles()">设置直播推流控件参数</button>
			<button onclick="start()">开始推流/开始直播</button>
			<button onclick="stop()">结束推流</button>
			<button onclick="pause()">暂停推流</button>
			<button onclick="resume()">恢复推流</button>
			<button onclick="switchCamera()">切换前后摄像头</button>
			<button onclick="snapshot()">快照</button>
			<button onclick="close()">关闭直播推流控件</button>
		</div>
		<script>
			document.addEventListener("plusready", function() {
				// 扩展API加载完毕，现在可以正常调用扩展API
				createLivePusher();
			}, false);
			var player = null;
			// 创建视频播放控件
			// https://www.w3school.com.cn/i/movie.ogg
			function createLivePusher() {
				if (!pusher) {
					pusher = plus.video.createLivePusher('livePusher', {
						url: 'rtmp://testlivesdk.v0.upaiyun.com/live/upyunb',
						mode: "FHD",
						beauty: 1,
						whiteness: 5,
						aspect: '9:16',
						top: '200px',
						left: "auto",
						width: '90%',
						height: '200px',
					});
					plus.webview.currentWebview().append(pusher);
				}
			}

			function start() {
				pusher.start(function() {
					console.log('Start pusher success!');
				}, function(e) {
					console.log('Start pusher failed: ' + JSON.stringify(e));
				});
			}

			function stop() {
				pusher.stop();
			}

			function setStyles() {
				pusher.setStyles({
					url: 'rtmp://push.live.dcloud.io/test/test123';
				});
			}

			function pause() {
				pusher.pause();
			}

			function resume() {
				pusher.resume();
			}

			function switchCamera() {
				pusher.switchCamera();
			}

			function snapshot() {
				pusher.snapshot(function(e) {
					plus.nativeUI.alert("snapshot success: " + JSON.stringify(e));
				}, function(e) {
					plus.nativeUI.alert("snapshot error: " + JSON.stringify(e));
				});
			}
			function close(){
				pusher.close();
			}
		</script>
	</body>
</html>
